<template>
  <div class="home-container">
    <!-- 欢迎标题 -->
    <div class="welcome-section">
      <h1 class="welcome-title">欢迎使用网络信号优化系统</h1>
      <p class="welcome-subtitle">专业的网络信号监测与优化解决方案</p>
    </div>

    <!-- 功能快捷按键 -->
    <div class="quick-actions-section">
      <h2 class="section-title">功能快捷入口</h2>
      <div class="quick-actions-grid">
        <el-card class="action-card" shadow="hover" @click="navigateTo('/home/device-management')">
          <div class="action-content">
            <el-icon class="action-icon"><Monitor /></el-icon>
            <div class="action-info">
              <h3>设备管理</h3>
              <p>查看和管理网络设备信息</p>
            </div>
          </div>
        </el-card>

        <el-card class="action-card" shadow="hover" @click="navigateTo('/home/signal-monitor')">
          <div class="action-content">
            <el-icon class="action-icon"><TrendCharts /></el-icon>
            <div class="action-info">
              <h3>信号监测</h3>
              <p>实时监测网络信号质量</p>
            </div>
          </div>
        </el-card>

        <el-card class="action-card" shadow="hover" @click="navigateTo('/home/task-management')">
          <div class="action-content">
            <el-icon class="action-icon"><List /></el-icon>
            <div class="action-info">
              <h3>任务管理</h3>
              <p>创建和管理优化任务</p>
            </div>
          </div>
        </el-card>

        <el-card class="action-card" shadow="hover" @click="navigateTo('/home/result-analysis')">
          <div class="action-content">
            <el-icon class="action-icon"><PieChart /></el-icon>
            <div class="action-info">
              <h3>结果分析</h3>
              <p>分析优化效果和统计数据</p>
            </div>
          </div>
        </el-card>
        
        <el-card class="action-card" shadow="hover" @click="navigateTo('/home/user-management')">
          <div class="action-content">
            <el-icon class="action-icon"><User /></el-icon>
            <div class="action-info">
              <h3>用户管理</h3>
              <p>管理系统用户账号</p>
            </div>
          </div>
        </el-card>
      </div>
    </div>

    <!-- 系统信息 -->
    <div class="system-info-section">
      <h2 class="section-title">系统信息</h2>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-card class="info-card">
            <template #header>
              <span>系统状态</span>
            </template>
            <div class="info-content">
              <el-icon class="status-icon success"><SuccessFilled /></el-icon>
              <span>运行正常</span>
            </div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="info-card">
            <template #header>
              <span>当前时间</span>
            </template>
            <div class="info-content">
              <el-icon><Clock /></el-icon>
              <span>{{ currentTime }}</span>
            </div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="info-card">
            <template #header>
              <span>用户信息</span>
            </template>
            <div class="info-content">
              <el-icon><User /></el-icon>
              <span>管理员</span>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import {
  Monitor,
  TrendCharts,
  List,
  PieChart,
  SuccessFilled,
  Clock,
  User
} from '@element-plus/icons-vue'

const router = useRouter()
const currentTime = ref('')

// 格式化当前时间
const formatCurrentTime = () => {
  const now = new Date()
  return now.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  })
}

// 页面跳转
const navigateTo = (path) => {
  router.push(path)
}

onMounted(() => {
  // 设置当前时间
  currentTime.value = formatCurrentTime()
  
  // 每秒更新一次时间
  setInterval(() => {
    currentTime.value = formatCurrentTime()
  }, 1000)
})
</script>

<style scoped>
.home-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-section {
  text-align: center;
  margin-bottom: 40px;
  padding: 40px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  color: white;
}

.welcome-title {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.welcome-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
}

.section-title {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #303133;
  border-left: 4px solid #409eff;
  padding-left: 12px;
}

.quick-actions-section {
  margin-bottom: 40px;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.action-card {
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.action-content {
  display: flex;
  align-items: center;
  padding: 20px;
}

.action-icon {
  font-size: 2.5rem;
  color: #409eff;
  margin-right: 20px;
}

.action-info h3 {
  margin: 0 0 8px 0;
  font-size: 1.2rem;
  color: #303133;
}

.action-info p {
  margin: 0;
  color: #909399;
  font-size: 0.9rem;
}

.system-info-section {
  margin-bottom: 40px;
}

.info-card {
  border: none;
}

.info-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.status-icon {
  font-size: 1.5rem;
}

.status-icon.success {
  color: #67c23a;
}

@media (max-width: 768px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .welcome-title {
    font-size: 2rem;
  }
  
  .welcome-subtitle {
    font-size: 1rem;
  }
}
</style>